use serde::{Deserialize, Serialize};
use surrealdb::sql::Thing;
use ts_rs::TS;

pub mod todo;
pub mod history;
pub mod indicators;
pub mod kline;
pub mod kline_flat;
pub mod malines;
pub mod matrix;
pub mod pattern;
pub mod point;
pub mod security;
pub mod table;
pub mod tick;
pub mod f10_bblance;
pub mod trade;
///
///
/// #[derive(Debug, Deserialize)]
///
/// struct Record {
///
///     #[allow(dead_code)]
///
///     id: Thing,
///
/// }
///
/// [Refer to Rust SDK](https://surrealdb.com/docs/surrealdb/integration/sdks/rust)
///
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, TS)]
#[ts(export)]
pub struct FudaRecord {
    #[allow(dead_code)]
    #[ts(as = "Option<FudaThing>")]
    pub id: Thing,
}

#[derive(Debug, Serialize, Deserialize, Default, TS)]
#[ts(export)]
pub struct FudaThing {
    tb: String,
    id: FudaThingId,
}

#[derive(Debug, Serialize, Deserialize, Default, TS)]
#[ts(export)]
pub struct FudaThingId {
    #[allow(non_snake_case)]
    String: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct In<T> {
    pub in_: T,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct Out<T> {
    pub out: T,
}

pub fn up2int(num: f64) -> i64 {
    (num * 100.0).round() as i64
}
